from django.test import TestCase
from pao.loader import DataLoader
from reports.personal import *
#from pao.reports.gedo_test import *
from reports.personal import personalReport, projectTasksReport
from reports.project import projectManagerReport, projectIntensityReport, projectBudgetReport
from menu.lists import *
from reports.department import *

from reports.enterprise import *
from charts.charts import *
from datetime import *
from django.contrib.auth.models import User

     
class SimpleTest(TestCase):

    def test_data_loader(self):
        # It is assumed that XSLX is extracted and files contained in temp dir
        
        # NEW ADMINS
        #names = ['aleliaaa', 'pniauman', 'ggumonis', 'wiktor.dulko']
        #for n in names:
        #    u = User()
        #    u.username = n
        #    u.set_password(n)
        #    u.is_active = True
        #    u.is_staff = True
        #    u.email = n + '@gmail.com'
        #    u.save()


        DataLoader('DUOMENYS.xlsx').updateDatabase()
         
        #print enterpriseBudgetReport()
        
        #a = projectIntensityReport(40)
        #print projectIntensityChart(a)
        #xlsx.readSharedStrings(xlsx.EXTRACT_DIR + 'xl/sharedStrings.xml')

        #cProfile.runctx('xlsx.updateDatabase()', {'xlsx':xlsx}, {}, 'profile')
        #xlsx.updateDatabase()
        #print xlsx.sharedStrings

        #tasksColumns = {'A': 'project', 'B': 'employee', 'C': 'year', 'D': 'month', 'E': 'workhours'}
        #for row in xlsx.readSheet('temp/xl/worksheets/sheet1.xml', tasksColumns):
        #    print row['project'], repr(row['employee']), row['year'], row['month'], row['workhours']

        #xlsx.readWorkbook('temp/xl/workbook.xml')
        #print xlsx.sheets
    
		#def test_reports(self):

        #Wiktoro testai:
        #print personalReport('Simonas')
        #print projectTasksReport('Aurimas', 10)
        #print projectTasksReport('Simonas', 64)
        #print projectManagerReport(159) #27
        #print projectIntensityReport(159, None, None)
        #print projectBudgetReport(159, None, None)
        #print projectIntensityReport(64, '2005-08-01', '2007-01-01')
        #print departmentLoadReport(4, None, None)
        #print enterpriseEmployeeLoadReport(None, None)
        print projectManagerReport(8);

        #-----   menu/lists.py
        #print projectsList('Simonas')
        #print managedProjectsList('Simonas')
        #print departmentProjectsList(4)
        #print departmentEmployeeList(4)
        #print departmentsList()
        #print employeeList()

        #Gedo testai
        if date.today().year % 4 == 0:
            year = timedelta(days=366)
        else:
            year = timedelta(days=365)

        #print departmentManagerReport(2)
        #print departmentProjectsReport(1)
        #print departmentProjectsReport(98,date((date.today()- year).year ,date.today().month,01),date(date.today().year ,date.today().month,01))
        #print departmentBudgetReport(98,date((date.today()- year).year ,date.today().month,01),date(date.today().year ,date.today().month,01))
        #execfile('pao/reports/test.py')=======
        #print departmentBudgetReport(12) 
        #execfile('pao/reports/test.py')

